home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 November: Tool Chest / Dev.CD Nov 96 TC / Dev.CD Nov 96 TC.toast / Sample Code / Snippets / Sound / SndPlayDoubleBuffer / _source / MyGestalt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-06  |  1.6 KB  |  65 lines  |  [TEXT/CWIE]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    Routines demonstrating how to call Gestalt.
  5. **
  6. **    by Mark Cookson, Apple Developer Technical Support
  7. **
  8. **    File:    MyGestalt.c
  9. **
  10. **    Copyright ©1996 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "Apple Sample
  17. **    Code" after having made changes. If you're going to re-distribute the
  18. **    source, we require that you make it clear in the source that the code
  19. **    was descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #include "MyGestalt.h"
  23.  
  24. OSErr InterrogateSystem    (sGlobalsPtr globals)
  25. {
  26.     long    attrib        = nil;
  27.     OSErr    theErr        = noErr;
  28.  
  29.     if (TrapAvailable (_Gestalt)) {
  30.         if (Gestalt (gestaltSoundAttr, &attrib) == noErr) {
  31.             globals->ggestaltSoundAttr = attrib;
  32.         }
  33.         if (Gestalt (gestaltStandardFileAttr, &attrib) == noErr) {
  34.             globals->ggestaltStandardFileAttr = attrib;
  35.         }
  36.     }
  37.     else {
  38.         theErr = kInitErr;
  39.     }
  40.  
  41.     return theErr;
  42. }
  43.  
  44. Boolean TrapAvailable    (short trapWord)
  45. {
  46.     TrapType    tType;
  47.     Boolean        returnValue;
  48.  
  49.     if (BitAnd(trapWord, 0x0800)) {
  50.         tType = ToolTrap;
  51.     }
  52.     else {
  53.         tType = OSTrap;
  54.     }
  55.     if (tType == ToolTrap && (BitAnd(trapWord, 0x03FF) >= 0x200) &&
  56.        GetToolboxTrapAddress(0xA86E) == GetToolboxTrapAddress(0xAA6E)) {
  57.         returnValue = false;
  58.     }
  59.     else {
  60.         returnValue = (NGetTrapAddress(trapWord, tType) != GetToolboxTrapAddress(_Unimplemented));
  61.     }
  62.  
  63.     return returnValue;
  64. }
  65.